package com.sxg.webSocket;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * @ClassDescription: websocket配置类
 * 该配置类用于创建ServerEndpoint注解，此注解用在类上，使得此类成为服务端websocket
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2023/8/31 14:56
 */
@Configuration
@EnableWebSocket
public class WebsocketConfig {
    @Bean
    public ServerEndpointExporter serverEndpointExporter(){
        return  new ServerEndpointExporter();
    }

    @Bean
    @Primary
    public TaskScheduler taskScheduler(){
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(200);
        taskScheduler.initialize();
        return taskScheduler;
    }

}
